﻿<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Cwjk_SetKjkm_MapBuild2.aspx.vb" Inherits="PubProject.Cwjk_SetKjkm_MapBuild2" %>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mwc" Namespace="MySoft.WebControls" Assembly="MySoft.WebControls" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Cwjk_SetKjkm_MapBuild2</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<LINK href="/_nav/menu.css" type="text/css" rel="stylesheet">
		<LINK href="/_common/styles/global.css" type="text/css" rel="stylesheet">
		<LINK href="/_grid/map_grid.css" type="text/css" rel="stylesheet">
		<LINK href="/_forms/styles/form.css" type="text/css" rel="stylesheet">
		<LINK href="/_common/styles/select.css" type="text/css" rel="stylesheet">
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/_forms/FormBase.js"></script>
		<script language="javascript" src="/_controls/setting.js"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_grid/rep_grid.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script language="javascript" src="Cwjk_Public.js"></script>
		<script language="javascript" src="Cwjk_SetKjkm_MapBuild.js"></script>
		<script language="javascript" src="/PubProject/js/Public.js"></script>
		<style>
			.scrollColThead {
			position: relative; 
			top: expression(this.parentElement.parentElement.parentElement.scrollTop);
			z-index:2;
			}
			NOBR{ OVERFLOW: hidden; WIDTH: 100%; TEXT-OVERFLOW: ellipsis }
		</style>
		<script language="javascript">
			//在线帮助文件
		    var _MyHelpfile = "/Cbgl/HELP/topics/财务人员/设置财务接口/设置辅助核算.html";
			
			var oldTr;
			
			function window.onload()
			{
				initGrid(gridBar);					//初始化 Repeater 中的表格(id=gridBar)
				
				setGridTitle(gridBar);	
				
				if (document.all("txtOperObject").value == "预约单")  reDisplay('btnBatch,btnLoadOut,btnLoadIn');
				
				if( document.all("__Application") && document.all("__Application").value=="0101")
                {
                    _MyHelpfile = "/Slxt/HELP/topics/财务管理/财务接口设置/设置辅助核算.html";
                }	
                
                if(document.all.txtIsExport.value=="Export")
                {
                   document.all.txtIsExport.value="";
                
                   ExportKjkmDetail();
                }				
			}
			
			function setGridTitle(ogrid)
			{
				var iRowsLen = ogrid.rows.length;
				
				oTr = ogrid.rows[0];
				switch (document.all("txtOperObject").value)
				{
					case "账套":
						appGridMenu.cells[0].innerHTML = "<B>账套科目对照列表";
						oTr.cells[2].innerText = "账套名称";
						break;
					case "银行":
						appGridMenu.cells[0].innerHTML = "<B>银行科目对照列表";
						oTr.cells[2].innerText = "入账银行";
						break;
					case "预约单":
						appGridMenu.cells[0].innerHTML = "<B>预约单科目对照列表";
						oTr.cells[2].innerText = "项目排号：预约单客户";
						break;
					case "款项名称":
					    appGridMenu.cells[0].innerHTML = "<B>款项名称科目对照列表";
					    oTr.cells[2].innerText = "款项名称";
					    break;
					case "产品类型全称":
					    appGridMenu.cells[0].innerHTML = "<B>产品类型全称科目对照列表";
					    oTr.cells[2].innerText = "产品类型全称";
					    break;
				}
				
				//默认第一行处于设置状态
				if (iRowsLen>1) setControl(ogrid.rows[1]);
			}
			
			function saveGridData()
			{
				if ( gridBar )
				{
				    try
	                {
		                //保存前禁止该权限点。
		                deActive("btnSave");
			        
				        if(gridBar.rows.length<=1)
				        {
				           alert("没有要保存的数据！");
		               		   document.all.txtIsExport.value="";		           
				           //出现异常恢复其权限点（由于该按钮必须有权限点才能执行此代码，故恢复权限点并不会造成权限影响）
			                reActive("btnSave");
				           return;				    
				        }
					    var ogrid = gridBar;
					    var sXML = getGridDataXML(ogrid);			//获得初始Grid中的数据，拼写成 XML 格式
    					
					    //校验是否有需要保存的行
					    if (!verifyGridRow(sXML)) return;
    					
					    var sFile = "/PubProject/CWJK/Cwjk_XMLHTTP.aspx";
					    var rdNum = Math.random();
					    sFile += "?openroot=" + escape(document.all("txtOpenRoot").value) + "&randnum=" + escape(rdNum);
    					
					    var sReturns = "";
					    sReturns = openCwjkXmlHTTP(sFile,"CWJK_MAP_SAVE",sXML);
    					
					    if (sReturns == "false")
					    {
						    alert("保存失败，请与系统管理员联系！");
						    document.all.txtIsExport.value=""; 
						    //出现异常恢复其权限点（由于该按钮必须有权限点才能执行此代码，故恢复权限点并不会造成权限影响）
			                reActive("btnSave");
					    }
					    else
					    {
					        if(document.all.txtIsExport.value!="Export")
                            {
						       alert("保存成功！");
						    }
						    document.all("txtPinYinCale").value = "SAVEOK";
						    __doPostBack("","");
					    }
				    }
			        catch(e)
			        {
			            //出现异常恢复其权限点（由于该按钮必须有权限点才能执行此代码，故恢复权限点并不会造成权限影响）
			            reActive("btnSave");
			        }
				}
			}
		
			function document_onkeyup()
			{
				if(window.event.keyCode == 13)
				{
					window.event.keyCode = 9;
				}
			}
			
			//功能：控制Grid中的光标移动
			function ChangeKeyCode(obj)
			{
				var objText = window.event.srcElement;
				var objTab = objText.parentElement.parentElement.parentElement;
				var tdCol = objText.parentElement.cellIndex;									//当前列
				var trRow = objText.parentElement.parentElement.rowIndex;						//当前行

				//按回车键转换为 Tab键
				if (trRow < (objTab.rows.length -1)  && (window.event.keyCode == 13))// || window.event.keyCode == 40))
				{
					//window.event.keyCode = 9;
					//if (tdCol == 5)	trRow += 1;
				}
				else
				{
					//按向下键则找到下一行的对象设置焦点
					if (trRow < (objTab.rows.length -1) && window.event.keyCode == 40)
					{
						trRow += 1;
						//objTab.rows(trRow).cells(tdCol).children(0).select();
						setControl(objTab.rows(trRow));
					}
					else
					{
						//按向上键则找到上一行的对象设置焦点
						if (trRow > 1 && window.event.keyCode == 38)
						{
							trRow -= 1;
							//objTab.rows(trRow).cells(tdCol).children(0).select();
							setControl(objTab.rows(trRow));
						}
					}
				}
				//加亮当前行
				objTab.rows(trRow).click();
			}
			
			function setControl(oTr)
		{
			var oSrc = event.srcElement;
			
			if (oldTr && oldTr == oTr) return;
			
			if (oTr) setTrReadOnly(oTr,true,oSrc);
			if (oldTr) setTrReadOnly(oldTr,false,oSrc);
			oldTr = oTr;
		}
		
		function setTrReadOnly(oTr,isReadOnly,oSrc)
		{
			if(oTr.cells.length>0 && isReadOnly)
			{
				//获得原来的值
				var sOld = Trim(oTr.cells["kmcode"].innerText);
				var sTmp = "<input id=\"kmcode\" type=\"text\" class=\"inputStr\" value=\"" + sOld + "\" forbiddenchars=\"@#?|,;'&quot;&amp;&lt;&gt;\" maxlength=\"80\" name=\"kmcode\" onkeyup=\"ChangeKeyCode('this')\" onkeydown =\"document_onkeyup()\">";
				oTr.cells["kmcode"].innerHTML = sTmp;
								
				sOld = Trim(oTr.cells["kmname"].innerText);
				sTmp = "<input id=\"kmname\" type=\"text\" class=\"inputStr\" value=\"" + sOld + "\" forbiddenchars=\"@#?|,;'&quot;&amp;&lt;&gt;\" maxlength=\"80\" name=\"kmname\" onkeyup=\"ChangeKeyCode('this')\" onkeydown =\"document_onkeyup()\">";
				oTr.cells["kmname"].innerHTML = sTmp;
				
				//设置光标位置
				if (oSrc)
				{
					switch (oSrc.id)
					{
						case "kmname":
							oTr.cells["kmname"].firstChild.focus();
							break;
						default :
							oTr.cells["kmcode"].firstChild.focus();
					}
				}
			}
			
			if(oTr.cells.length>0 && !isReadOnly)
			{
				var sOld;
				if(oTr.cells["kmcode"].firstChild&&oTr.cells["kmcode"].firstChild.value)
				{
					sOld = Trim(oTr.cells["kmcode"].firstChild.value);
				}
				else
				{
					sOld = Trim(oTr.cells["kmcode"].innerText)
				}
				
				if (sOld == "") sOld = "&nbsp;"; 
				oTr.cells["kmcode"].innerHTML = sOld;
				
				if(oTr.cells["kmname"].firstChild&&oTr.cells["kmname"].firstChild.value)
				{
					sOld = Trim(oTr.cells["kmname"].firstChild.value);
				}
				else
				{
					sOld = Trim(oTr.cells["kmname"].innerText)
				}
				if (sOld == "") sOld = "&nbsp;"; 
				oTr.cells["kmname"].innerHTML = sOld;
			}
		}
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="crmForm" method="post" runat="server">
			<asp:linkbutton id="LinkButton1" runat="server" CssClass="hidden"></asp:linkbutton>
			<asp:textbox id="txtIsExport" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtCwztGUID" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtBz" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtKmTypeGUID" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtOperObject" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtOpenRoot" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtRptRule" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtHsType" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtPinYinCale" runat="server" style="DISPLAY:none"></asp:textbox>
			<asp:textbox id="txtApplication" runat="server" style="DISPLAY:none"></asp:textbox>
			<table style="TABLE-LAYOUT: fixed;FONT-SIZE: 9pt" height="100%" cellSpacing="0" cellPadding="0"
				width="100%">
				<TBODY>
					<tr height="25">
						<td><mnu:appgridmenu id="appGridMenu" runat="server"></mnu:appgridmenu></td>
					</tr>
					<tr>
						<td>
							<mwc:repeater id="Repeater1" runat="server" SortSignASC='<img src="/_imgs/ico_arrow_u.gif">' SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">'
								EnablePager="true">
								<HeaderTemplate>
									<table width="100%" height="95%"  style="TABLE-LAYOUT: fixed;FONT-SIZE: 9pt" cellspacing="0"
										cellpadding="0" border="0" bordercolor="red">
										<tr height="100%" valign="top">
											<td>
												<div style="OVERFLOW: auto; WIDTH: 100%; HEIGHT: 100%">
													<table id="gridBar" width="100%" onclick="handleClick();"  cellpadding="0" cellspacing="0"
														border="0" MultiSelect="true" gridID="Repeater1" style="TABLE-LAYOUT: fixed">
														<colgroup id="gridBarCols">
															<col width="40">
															<col width="2">
															<col>
															<col width="2">
															<col width="120">
															<col width="2">
															<col width="140">
															<col width="2">
															<COL width="14">
														</colgroup>
														<tr id="trHeader" align="center" class="scrollColThead"   height="23" style="cursor:hand" pagesize="15">
															<td align="center" class="gridBar" noWrap>序号</td>
															<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
															<td class="gridBar" noWrap><nobr></nobr></td>
															<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
															<td class="gridBar" noWrap><nobr>科目代码</nobr></td>
															<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
															<td class="gridBar" noWrap><nobr>科目名称</nobr></td>
															<td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
															<TD class="gridBar" width="14"><IMG onclick="__doPostBack('REFRESH');" alt="刷新表格" src="/_imgs/grid_Refresh.gif"></TD>
														</tr>
								</HeaderTemplate>
								<ItemTemplate>
									<tr height="24" onclick="setControl(this)" oid='<%# DataBinder.Eval(Container.DataItem, "KjkmMapGUID") %>' objectguid='<%# DataBinder.Eval(Container.DataItem, "ObjectGUID") %>' entity='<%# DataBinder.Eval(Container.DataItem, "entity") %>' cwztguid='<%# DataBinder.Eval(Container.DataItem, "CwztGUID") %>' kmtypeguid='<%# DataBinder.Eval(Container.DataItem, "KmtypeGUID") %>' operobject='<%# DataBinder.Eval(Container.DataItem, "OperObject") %>' buguid='<%# DataBinder.Eval(Container.DataItem, "BUGUID") %>'>
										<td align="center" colspan="2" noWrap><%# DataBinder.Eval(Container.DataItem, "rowid") %></td>
										<td colspan="2" name="objectname" noWrap><%# DataBinder.Eval(Container.DataItem, "ObjectName") %></td>
										<td colspan="2" id="kmcode" name="kmcode" noWrap><%# DataBinder.Eval(Container.DataItem, "KmCode") %></td>
										<td colspan="2" id="kmname" name="kmname" noWrap><%# DataBinder.Eval(Container.DataItem, "KmName") %></td>
										<TD>&nbsp;</TD>
									</tr>
								</ItemTemplate>
								<FooterTemplate>
			</table>
			</div></td></tr> </table> </FooterTemplate> </mwc:repeater></form>
		</TD></TR></TBODY></TABLE>
	</body>
</HTML>
